package cmd

import (
	"github.com/spf13/cobra"
	"github.com/duke-git/lancet/netutil"
	"im-tools/internal/config"
	"fmt"
	"github.com/gookit/color"
)

var logoutCmd = &cobra.Command{
	Use:   "logout",
	Short: "注销",
	Long:  `注销系统`,
	Run: func(cmd *cobra.Command, args []string) {
		request := &netutil.HttpRequest{
			RawURL: config.API + "/api/zkim/sys/userLogOut",
			Method: "POST",
		}
		httpClient := netutil.NewHttpClient()
		resp, err := httpClient.SendRequest(request)
		if err != nil || resp.StatusCode != 200 {
			fmt.Println(resp.StatusCode)
			return
		}
		Token = ""
		LoginedUserId=""
		IMToken=""
		LoginedDeviecode=""
		color.Info.Println("成功注销")
	},
}

func init() {
	rootCmd.AddCommand(logoutCmd)
}